<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
                xmlns:cs="http://myfaces.apress.com/custom"
				template="/WEB-INF/layouts/standard.xhtml"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:bf="http://www.bssmanager.com/jsf"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:fn="http://java.sun.com/jsp/jstl/functions">


	<ui:define name="formheader">
		<h2>Daily Revenue</h2>
	</ui:define>
	
	
	<ui:define name="content">
		<h:form id="#{dailyRevenueController.modelName}" >
			<rich:panel style="border:0px;">
					
				<table width="100%" align="left" style="text-align: left; table-layout: fixed">			
					<tr style="background-color: #FFBF80">
						<td colspan="1" style="font-weight: bolder; font-size: 10pt;" align="left">
							Todays Revenues
						</td>
						<td colspan="1" style="font-weight: bolder; font-size: 10pt;" align="left">
							Last Report Generated
						</td>
					</tr>
					<tr>				
						<td valign="top"><div style="background-color: yellow;"></div>								
								<h:panelGrid columns="3">									
									<h:outputLabel value="Date: "/>
									<rich:calendar enableManualInput="false" value="#{dailyRevenueController.model.date}" inputSize="12"
										datePattern="dd MMM yy HH:mm">
										<a4j:support event="onchanged" reRender="total,paymentTotal" 
											action="#{dailyRevenueController.doTotal}" status="drdate" />
									</rich:calendar>
										<a4j:status forceId="true" id="drdate" >
											 <f:facet name="start">
								                  <h:graphicImage value="/images/im1.gif"/>
								             </f:facet>
										</a4j:status>								
								</h:panelGrid>
								<h:panelGrid columns="3">
									<h:outputLabel value="Room Rent(#{dailyRevenueController.model.payments[0].id} - #{dailyRevenueController.model.payments[fn:length(dailyRevenueController.model.payments) - 1].id})"/>									
									<h:outputText id="paymentTotal" value="#{dailyRevenueController.model.total == 0 ? 'N/A': dailyRevenueController.model.total}" style="text-align:right; float:right;"/>
									<h:outputText value=" "/>
									<c:forEach items="#{dailyRevenueController.model.revenues}" var="revenue" varStatus="status11">
										<h:outputLabel value="#{revenue.revenueHead.name}"/>
										<h:inputText size="3" value="#{revenue.amount}" style="text-align:right" >
											<a4j:support event="onchange" reRender="total" action="#{dailyRevenueController.doTotal}" status="nnn-#{status11.index}" />
										</h:inputText>
										<a4j:status forceId="true" id="nnn-#{status11.index}" >
											 <f:facet name="start">
								                  <h:graphicImage value="/images/im1.gif"/>
								             </f:facet>
										</a4j:status>															
									</c:forEach>
								
									<h:outputLabel value="Total: " style="font-weight:bold"/>
									<h:outputText id="total" value="#{dailyRevenueController.model.total}" style="font-weight:bold; color: green; text-align:right; float:right;"/>
									<h:outputText value=" "/>
								</h:panelGrid>
								<div align="center">
									<h:commandButton value="Add" action="#{dailyRevenueController.add}"/>
								</div>								
						</td>
						<td valign="top" align="left">								
							<h:outputText value="#{dailyRevenueController.model.lastReportGeneratedDate}" style="background-color: yellow;">
								<f:convertDateTime pattern="dd MMM yy HH:mm" />
							</h:outputText>
						</td>
					</tr>			
				</table>					
			</rich:panel>				
		</h:form>		
	</ui:define>
</ui:composition>